﻿using _2112A_2_MES._chubowen;
using _2112A_2_MES._sujiahao;
using _2112A_2_MES._wangweihao;
using _2112A_2_MES._XiangHe;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.BackgroundJobs.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.FeatureManagement.EntityFrameworkCore;
using Volo.Abp.Identity;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.OpenIddict.EntityFrameworkCore;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TenantManagement;
using Volo.Abp.TenantManagement.EntityFrameworkCore;

namespace _2112A_2_MES.EntityFrameworkCore;

[ReplaceDbContext(typeof(IIdentityDbContext))]
[ReplaceDbContext(typeof(ITenantManagementDbContext))]
[ConnectionStringName("Default")]
public class _2112A_2_MESDbContext :
    AbpDbContext<_2112A_2_MESDbContext>,
    IIdentityDbContext,
    ITenantManagementDbContext
{
    /* Add DbSet properties for your Aggregate Roots / Entities here. */

    #region Entities from the modules

    /* Notice: We only implemented IIdentityDbContext and ITenantManagementDbContext
     * and replaced them for this DbContext. This allows you to perform JOIN
     * queries for the entities of these modules over the repositories easily. You
     * typically don't need that for other modules. But, if you need, you can
     * implement the DbContext interface of the needed module and use ReplaceDbContext
     * attribute just like IIdentityDbContext and ITenantManagementDbContext.
     *
     * More info: Replacing a DbContext of a module ensures that the related module
     * uses this DbContext on runtime. Otherwise, it will use its own DbContext class.
     */

    //Identity
    public DbSet<IdentityUser> Users { get; set; }
    public DbSet<IdentityRole> Roles { get; set; }
    public DbSet<IdentityClaimType> ClaimTypes { get; set; }
    public DbSet<OrganizationUnit> OrganizationUnits { get; set; }
    public DbSet<IdentitySecurityLog> SecurityLogs { get; set; }
    public DbSet<IdentityLinkUser> LinkUsers { get; set; }
    public DbSet<IdentityUserDelegation> UserDelegations { get; set; }
    public DbSet<IdentitySession> Sessions { get; set; }
    // Tenant Management
    public DbSet<Tenant> Tenants { get; set; }
    public DbSet<TenantConnectionString> TenantConnectionStrings { get; set; }

    #region 王炜豪
    public DbSet<Barcode> Barcodes { get; set; }
    public DbSet<Client> Clients { get; set; }
    public DbSet<IncomingTest> IncomingTestses { get; set; }
    public DbSet<PendinginspectionTasks> PendinginspectionTaskses { get; set; }
    public DbSet<PrintprinterConfig> PrintprinterConfigs { get; set; }
    public DbSet<PrintTemplate> PrintTemplates { get; set; }
    public DbSet<Proroute> Proroutes { get; set; }
    public DbSet<ProRouteProcess> ProRouteProcesses { get; set; }
    public DbSet<ShiftPlan> ShiftPlans { get; set; }
    public DbSet<Statement> Statements { get; set; }
    public DbSet<StockDetail> StockDetails { get; set; }
    public DbSet<StockTaking> StockTakings { get; set; }
    public DbSet<StockTakingLine> StockTakingLines { get; set; }
    public DbSet<StorageArea> StorageAreas { get; set; }
    public DbSet<StorageLocation> StorageLocations { get; set; }
    public DbSet<Tool> Tools { get; set; }
    public DbSet<ToolType> ToolTypes { get; set; }
    public DbSet<WmBarcodeConfig> WmBarcodeConfigs { get; set; }
    public DbSet<Workstation> Workstations { get; set; }
    #endregion

    #region 楚博文
    public DbSet<CalTeam> CalTeam { get; set; }
    public DbSet<CalTeamMember> CalTeamMember { get; set; }
    public DbSet<DefectModel> DefectModel { get; set; }
    public DbSet<DefectTypeModel> DefectTypeModel { get; set; }
    public DbSet<Inspection> Inspection { get; set; }
    public DbSet<InspectionType> InspectionType { get; set; }
    public DbSet<MdItem> MdItem { get; set; }
    public DbSet<MdItemType> MdItemType { get; set; }
    public DbSet<ProductionPiicking> ProductionPiicking { get; set; }
    public DbSet<ProductionPiickingSingle> ProductionPiickingSingle { get; set; }
    public DbSet<ProductionRejection> ProductionRejection { get; set; }
    public DbSet<ProductionRejectionSingle> ProductionRejectionSingle { get; set; }
    public DbSet<ProFeedback> ProFeedback { get; set; }
    public DbSet<ProProcess> ProProcess { get; set; }
    public DbSet<ProWorkOrder> ProWorkOrder { get; set; }
    public DbSet<ProWorkorderBom> ProWorkorderBom { get; set; }
    public DbSet<WmItemRecpt> WmItemRecpt { get; set; }
    public DbSet<WmItemRecpt2> WmItemRecpt2 { get; set; }
    #endregion

    #region 苏佳豪
    public DbSet<CalHoliday> CalHolidays { get; set; }
    public DbSet<CalHolidayTwo> CalHolidayTwos { get; set; }
    public DbSet<CalPlanTeam> CalPlanTeams { get; set; }
    public DbSet<CalShift> CalShifts { get; set; }
    public DbSet<DvCheckMachinery> DvCheckMachinerys { get; set; }
    public DbSet<DvCheckPlan> DvCheckPlans { get; set; }
    public DbSet<DvMachineryType> DvMachineryTypes { get; set; }
    public DbSet<DvRepair> DvRepairs { get; set; }
    public DbSet<DvRepairLine> DvRepairLines { get; set; }
    public DbSet<DvSubject> DvSubjects { get; set; }
    public DbSet<MdWorkshop> MdWorkshops { get; set; }
    public DbSet<OcDeffect> OcDeffects { get; set; }
    public DbSet<QcIpqc> QcIpqcs { get; set; }
    public DbSet<QcIpqcLine> QcIpqcLines { get; set; }
    public DbSet<WmPackage> WmPackages { get; set; }
    public DbSet<WmTransfer> WmTransfers { get; set; }
    public DbSet<WmTransferLine> WmTransferLines { get; set; }
    public DbSet<WmpackageLine> WmpackageLines { get; set; }
    #endregion

    #region 项鹤
    public DbSet<MdVendor> MdVendors{ get; set; }
    public DbSet<Measures> Measuress{ get; set; }
    public DbSet<ProductEntryForm> ProductEntryForms{ get; set; }
    public DbSet<ProductSales> ProductSaless{ get; set; }
    public DbSet<ProductSalseLine> ProductSalseLines{ get; set; }
    public DbSet<ProductWarehousing> ProductWarehousings{ get; set; }
    public DbSet<Qcoqc> Qcoqcs{ get; set; }
    public DbSet<QcoqcLine> QcoqcLines{ get; set; }
    public DbSet<SalesReturn> SalesReturns{ get; set; }
    public DbSet<SalesReturnSingle> SalesReturnSingles{ get; set; }
    public DbSet<SalseLine> SalseLines{ get; set; }
    public DbSet<Sasle> Sasles{ get; set; }
    public DbSet<WmOutSource> WmOutSources{ get; set; }
    public DbSet<WmOutSourceIssue> WmOutSourceIssues{ get; set; }
    public DbSet<WmOutSourceIssueLine> WmOutSourceIssueLines{ get; set; }
    public DbSet<WmOutSourceLine> WmOutSourceLines{ get; set; }
    public DbSet<Wmsns> Wmsnss{ get; set; }
    public DbSet<WmWarehouse> WmWarehouses { get; set; }
    #endregion

    #endregion

    public _2112A_2_MESDbContext(DbContextOptions<_2112A_2_MESDbContext> options)
        : base(options)
    {

    }

    protected override void OnModelCreating(ModelBuilder builder)
    {
        base.OnModelCreating(builder);

        /* Include modules to your migration db context */

        builder.ConfigurePermissionManagement();
        builder.ConfigureSettingManagement();
        builder.ConfigureBackgroundJobs();
        builder.ConfigureAuditLogging();
        builder.ConfigureIdentity();
        builder.ConfigureOpenIddict();
        builder.ConfigureFeatureManagement();
        builder.ConfigureTenantManagement();

        /* Configure your own tables/entities inside here */

        //builder.Entity<YourEntity>(b =>
        //{
        //    b.ToTable(_2112A_2_MESConsts.DbTablePrefix + "YourEntities", _2112A_2_MESConsts.DbSchema);
        //    b.ConfigureByConvention(); //auto configure for the base class props
        //    //...
        //});
    }
}
